package com.zqt.zqt805.service.Impl;

import com.zqt.zqt805.domain.User;
import com.zqt.zqt805.mapper.UserMapper;
import com.zqt.zqt805.service.UserService;
import com.zqt.zqt805.util.AjaxResult;
import com.zqt.zqt805.util.HttpStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public void register(User user) {
        userMapper.insertUser(user);
    }

    @Override
    public String login(String username, String password) {
        User user = userMapper.selectUserByUsername(username);
        if (user != null && user.getPassword().equals(password)) {
            return "Login successful";
        }
        return "Invalid username or password";
    }

    @Override
    public User getUserById(int userId) {
        User user = userMapper.selectUserById(userId);
        return user;
    }


}